function myObjectCreate(prototype) {
  if (typeof prototype !== 'object') {
    throw new TypeError('Object prototype may only be an Object or null')
  }
  function F() {}
  F.prototype = prototype
  return new F()
}
// 性能不佳
function myObjectCreate2(prototype) {
  const obj = {}
  obj.__proto__ = prototype
  return obj
}

const obj = {
  a: 1,
  b: 2,
  hello() {
    console.log('hello')
  },
}

const obj2 = myObjectCreate(obj)
console.log(obj2)
console.log(obj2.a)
